package com.zhangwei.yueshijia.model;

import com.zhangwei.yueshijia.api.BaseSubscriber;
import com.zhangwei.yueshijia.api.RetrofitManager;
import com.zhangwei.yueshijia.bean.BaseBean;
import com.zhangwei.yueshijia.bean.home.HomeData;

import java.util.Map;

import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * OKhhtp + retrofit
 * Ansynchttp- android
 * Volley
 * NoHttp
 * image/*
 * application/text
 * application/json
 *
 *
 * 第一步  声明接口 声明请求的Http API
 * 第二步  实例化Retrofit对象 ,实例化声明的接口对象
 * 第三步  实例化Call对象
 * 第四步  发起请求
 * 第五步  处理返回结果
 */
public class HomeModel {

    public void getHomeData(Map<String, String> params, BaseSubscriber<BaseBean<HomeData>> subscriber) {

        Observable<BaseBean<HomeData>> observable = RetrofitManager.getSingleton()
                .getApiService()
                .getHomeData(params);

        observable
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

}
